package sala.components
{
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.text.TextFormatAlign;
	
	/**
	 * ...
	 * @author JS
	 */
	public class ExButton extends Sprite
	{
		private var _label:String;
		public var data:String;
		private var tf:TextField;
		public function ExButton( text:String, pWidth:uint = 80, pHeight:uint = 20) 
		{
			super();
			data = text;
			
			_label = text;
			
			this.buttonMode = true;
			this.mouseChildren = false;
			
			this.graphics.beginFill( 0xFFFFFF, 1 );
			this.graphics.drawRect( 0, 0, pWidth, pHeight );
			this.graphics.endFill();
			
			tf = new TextField();
			addChild( tf );
			tf.defaultTextFormat = new TextFormat( "_sans", 11, 0x000000, true, null, null, null, null, TextFormatAlign.CENTER );
			tf.embedFonts = false;
			tf.mouseEnabled = false;
			tf.width = pWidth;
			tf.height = 20;
			tf.x = 0;
			tf.y = ( pHeight - tf.height ) / 2;
			tf.text = text;
			this.addEventListener(MouseEvent.CLICK, mouseClickHdl);
			this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHdl);
			this.addEventListener(MouseEvent.MOUSE_UP, mouseUpHdl);
		}
		
		private function mouseUpHdl(e:MouseEvent):void 
		{
			tf.textColor = 0x000000;
		}
		
		private function mouseDownHdl(e:MouseEvent):void 
		{
			tf.textColor = 0x777777;
		}
		
		public function setLabel(label:String):void
		{
			tf.text = label;
		}
		
		private function mouseClickHdl(e:MouseEvent):void 
		{
		}
		
		public function get label():String
		{
			return _label;
		}
		
	}

}